package student.service;
import student.entity.Studentt;
import student.service.StudenttService;
import student.service.StudenttServiceImpl;

import java.util.Scanner;
public class StudenttServiceImpl implements StudenttService{
    public static Studentt studentt;
    public static int loginError;
    @Override
    public void initializeStudent(){
        studentt=new Studentt();
        studentt.setLoginTname("zhangxue");
        studentt.setLoginTpassword("123456");
        studentt.setStudentName("学生");
        loginError=5;
    }
    @Override
    public void studenttLogin(){
        for(int error=1;error<=loginError;error++){
            System.out.println("------学生登录------");
            Scanner scanner=new Scanner(System.in);
            System.out.print("请输入学生账号：");
            String loginName= scanner.next();
            System.out.print("请输入学生密码：");
            String loginPassword= scanner.next();
            if (studentt.getLoginTname().equals(loginName) && studentt.getLoginTpassword().equals(loginPassword)) {
                System.out.println("欢迎"+studentt.getStudentName()+"登录");
                new StudentServiceImpl().studentMenu();
                return;
            }else {
                System.out.println("账号或密码错误请重新输入，以错误" + error + "次,超过" + loginError + "自动退出到登录页面");
                if (error==loginError){
                    System.out.println("尝试次数过多，自动退出中");
                    return;
                }
            }
        }
    }
}
